package com.anxin.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.anxin.bean.Type;
import com.anxin.dao.TypeDAO;
import com.anxin.service.TypeService;
import com.anxin.util.PageListData;

@Service("typeService")
public class TypeServiceImpl implements TypeService {

	private TypeDAO dao;

	@Transactional
	public void save(Type proj) {
		dao.save(proj);
	}

	@Transactional
	public void delete(Type proj) {
		dao.delete(proj);
	}

	@Transactional
	public void delete(Integer id) {
		dao.delete(Type.class, id);
	}

	@Transactional
	public void update(Type proj) {
		dao.update(proj);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public PageListData queryPage(Map param, int pageNum, int pageSize) {
		param.put("start", (pageNum - 1) * pageSize);
		param.put("limit", pageSize);
		return dao.queryPage(Type.class, param, pageNum, pageSize);
	}

	public Type findById(Integer id) {
		return dao.findById(Type.class, id);
	}

	public List<Type> findAll() {
		return dao.findAll(Type.class);
	}

	@Override
	public List<Type> findTypeByParent(int parentId) {
		return dao.findTypeByParent(parentId);
	}

	@Autowired
	public void setTypeDao(TypeDAO dao) {
		this.dao = dao;
	}

}
